﻿using Microsoft.EntityFrameworkCore;
using MySql.Data.MySqlClient;
using SCRS.Model;

namespace SCRS.Db;

public class DbHelper:DbContext
{
    public DbSet<Account> Accounts { get; set; }
    public DbSet<Commodity> Commodities { get; set; }
    public DbSet<LoggerRecord> LoggerRecords { get; set; }
    public DbSet<OrderDetail> OrderDetails { get; set; }
    public DbSet<OrderInfo> OrderInfos { get; set; }
    public DbSet<StorageRecord> StorageRecords { get; set; }
    public DbSet<VipCard> VipCards { get; set; }
    public DbSet<VipPayRecord> VipPayRecords { get; set; }

    public static readonly DbHelper Instance = new DbHelper();


    protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
    {
        MySqlConnectionStringBuilder builder = new MySqlConnectionStringBuilder
        {
            Server = "localhost",
            Port = 3307,
            UserID = "root",
            Password = "root",
            Database = "scrs"
        };
        optionsBuilder.UseMySQL(builder.ConnectionString);
    }
}